import Vue from 'vue'
import reshandler from 'services/response-handler'
/*
 * 更新个人信息
 */
function makeUpdateUserInfoData(response) {
  return Object.assign({}, response, {})
}

/*
 * 更改密码
 */
function makeUpdatePwdData(response) {
  return Object.assign({}, response, {})
}

/*
 * 更改手机号
 */
function makeUpdateMobileByPwdData(response) {
  return Object.assign({}, response, {})
}

/*
* 发送验证码
*/
function makeSendValidateCodeData(response) {
  return Object.assign({}, response, {})
}

/*
 * 问题投诉与反馈
 */
function makeAddAdviceData(response) {
  return Object.assign({}, response, {})
}

export default {
  // 更新用户信息
  UpdateUserInfo: function (params, success, fail) {
    // request 
    params = Object.assign({}, params, {
      methodName: "UpdateUserInfo",
    })

    // invoke
    this.$.get(params)
      .then(reshandler.success(success, fail, makeUpdateUserInfoData), reshandler.error(fail))
  },

  // 更改密码
  UpdatePwd: function (params, success, fail) {
    // request 
    params = Object.assign({}, params, {
      methodName: "UpdatePwd",
    })

    // invoke
    this.$.get(params)
      .then(reshandler.success(success, fail, makeUpdatePwdData), reshandler.error(fail))

  },

  // 更改手机号码
  UpdateMobileByPwd: function (params, success, fail) {
    // request 
    params = Object.assign({}, params, {
      methodName: "UpdateMobileByPwd",
    })

    // invoke
    this.$.get(params)
      .then(reshandler.success(success, fail, makeUpdateMobileByPwdData), reshandler.error(fail))
  },

  // 问题投诉与反馈
  AddAdvice: function (params, success, fail) {
    // request 
    params = Object.assign({}, params, {
      methodName: "AddAdvice",
    })

    // invoke
    this.$.get(params)
      .then(reshandler.success(success, fail, makeAddAdviceData), reshandler.error(fail))
  },

  // 发送验证码
  SendValidateCode(params, success, fail) {
    // request 
    params = Object.assign({}, params, {
      methodName: "SendValidateCode",
    })

    // invoke
    this.$.get(params)
      .then(reshandler.success(success, fail, makeSendValidateCodeData), reshandler.error(fail))
  }
}